package com.wg.springboot.thread.FutureDemo;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class FutureDemo {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<Integer>  futureTask=new FutureTask<Integer>(()->{
            int sum=100;
            for (int i=1;i<100;i++){
                sum+=i;
            }
            return sum;
        });
        new Thread(futureTask).start();//开始线程
        Integer integer = futureTask.get();//返回计算后的结果
    }
}
